#ifndef __AS_SCROLL_TEXT__H__
#define __AS_SCROLL_TEXT__H__

#include "ASControl.h"
#include "ASImage.h"

typedef struct
{
    /* base */
    as_control base;

    /* attributes */
    ASINT timer_id;
    as_timer_cb timer_cb;
    ASUINT text_color;
    ASUINT bg_color;
    ASUINT focus_bg_color;
    ASINT if_need_scroll;
    ASINT if_focused;
    ASINT text_paint_len;
    ASINT period;
    ASWCHAR* text;
    as_image* bg_img;
    as_image* focus_bg_img;
    //used internal
    ASINT off_set;
    as_rect valid_show_area;//just show in this area
    ASBOOL if_small;

    /* methods */
    as_ret (*set_text)(as_control* ctrl_p, ASWSTR text);
    as_ret (*set_focus)(as_control* ctrl_p, ASINT if_focus);
    as_ret (*set_text_color)(as_control* ctrl_p, ASUINT text_color);
    as_ret (*set_bg_color)(as_control* ctrl_p, ASUINT bg_color);
    as_ret (*set_focus_bg_color)(as_control* ctrl_p, ASUINT bg_color);
    as_ret (*set_bg_img)(as_control* ctrl_p, as_image_src_type type, ASWSTR path);
    as_ret (*set_focus_bg_img)(as_control* ctrl_p, as_image_src_type type, ASWSTR path);
    as_ret (*set_valid_show_area)(as_control* ctrl_p, as_rect* rect_p);
    as_ret (*set_if_small)(as_control* ctrl_p, ASBOOL if_small);
    as_ret (*pause)(as_control* ctrl_p);
    as_ret (*resume)(as_control* ctrl_p);
} as_scrolltext;

/*
 *	[description] create a scroll text control
 *  [param] paint_buf : which buffer do you want to paint
 *  [param] area : area of this control
 *  [param] text : text want to show
 *  [param] text_color : text color
 *  [param] bg_color : background color
 *  [return] as_scrolltext* : if NULL , means create failed.
 *                       else return the pointer of scroll text.
 */
as_scrolltext* as_ctrl_scrolltext_create(as_rect area, ASWSTR text, ASUINT text_color, ASUINT bg_color);

/*
 *	[description] destroy an existed scroll text
 *  [param] ctrl_scrolltext_p : pointer of scroll text control
 *  [return] as_ret : AS_OK means destroy successful,otherwise are abnormal.
 */
as_ret as_ctrl_scrolltext_destroy(as_scrolltext* ctrl_scrolltext_p);

#endif//__AS_SCROLL_TEXT__H__